package projet.volleystat;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class MainActivity extends Activity {
	protected Button matchb;
	protected Button statsb;
	protected Button gestb;
	protected Button quitb;
	private AdView adView;
	private LinearLayout linearLayout;
	
	public void AjouterPub() {
		System.out.println("Tentative ajout pub");
		
		adView = new AdView(this, AdSize.BANNER,
				"ca-app-pub-5877482921932076/7389501148");
		
		
		System.out.println("start pub");
		linearLayout.addView(adView, 0);
		System.out.println("start pub");
		adView.loadAd(new AdRequest());
	}
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		System.out.println("Start activity");
		setContentView(R.layout.activity_main);
		System.out.println("Display main");
		matchb = (Button) findViewById(R.id.matchButton);
		linearLayout = (LinearLayout) findViewById(R.id.mainLayout);
		AjouterPub();
		matchb.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getBaseContext(),
						PrepMatchActivity.class);
				intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION);
				startActivity(intent);
			}
		});

		statsb = (Button) findViewById(R.id.statsButton);
		statsb.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getBaseContext(),
						StatsActivity.class);
				intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION);
				startActivity(intent);
			}
		});

		gestb = (Button) findViewById(R.id.gestButton);
		gestb.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getBaseContext(),
						GestionActivity.class);
				intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION);
				startActivity(intent);
			}
		});

		quitb = (Button) findViewById(R.id.quitButton);
		quitb.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}

}